package com.example.springstatemachine.listener;

import com.example.springstatemachine.consant.DocumentEvents;
import com.example.springstatemachine.consant.DocumentStates;
import org.springframework.statemachine.listener.StateMachineListenerAdapter;
import org.springframework.statemachine.state.State;
import org.springframework.stereotype.Component;

@Component
public class DocumentStateChangeListener extends StateMachineListenerAdapter<DocumentStates, DocumentEvents> {

    @Override
    public void stateEntered(State<DocumentStates, DocumentEvents> state) {
        System.out.println("State entered: " + state.getId());
        // 在这里可以添加更多的业务逻辑，例如记录日志
    }

    @Override
    public void stateExited(State<DocumentStates, DocumentEvents> state) {
        System.out.println("State exited: " + state.getId());
        // 在这里可以添加更多的业务逻辑，例如记录日志
    }

    @Override
    public void stateChanged(State<DocumentStates, DocumentEvents> from, State<DocumentStates, DocumentEvents> to) {
        System.out.println("State changed from " + from.getId() + " to " + to.getId());
        // 在这里可以添加更多的业务逻辑，例如记录日志
    }
}